$(document).ready(function() {
    if (window.history && window.history.pushState) {
        $(window).on('popstate', function () {
            window.history.pushState('forward', null, '#');
            window.history.forward(1);
        });
    }
    $("#share").on("click", function () {
        $(".page4_share_overlay").css('display', 'block');
    });
    $(".page4_share_overlay").on("click", function () {
        $(this).css('display', 'none');
    });
    $("#_repeat").on("click", function () {
        window.location.href = '/';
    });
    var time = 0;
    var startPosition, endPosition, moveLength;
    $(document).bind('touchstart', function(e) {
        var touch = e.touches[0];
        startPosition = {
            y: touch.pageY
        }
    }).bind('touchmove', function(e) {
        var touch = e.touches[0];
        endPosition = {
            y: touch.pageY
        };
        moveLength = endPosition.y - startPosition.y;
        if (Math.abs(moveLength) > 60) {
            if ( time == 0) {
                location.href = '#pagetitle';
                time = 1;
            }

        }
    });
})
